package com.atguigu.spzx.product.api;

import com.atguigu.spzx.product.dto.ProductSkuDetailRespDto;
import com.atguigu.spzx.product.dto.SkuSaleNumUpdateReqDto;
import com.atguigu.spzx.product.service.ProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * ProductController
 * </p>
 *
 * @author flyduck
 * @since 2023/11/3
 */
@Api(tags = "商品管理接口")
@RestController
@RequestMapping("/api/product")
public class ProductApiController {

    @Autowired
    private ProductService productService;

    @ApiOperation("更新商品sku销量")
    @PostMapping("/updateSkuSaleNum")
    public void updateSkuSaleNum(@RequestBody List<SkuSaleNumUpdateReqDto> skuSaleNumUpdateReqDtoList) {
        productService.updateSkuSaleNum(skuSaleNumUpdateReqDtoList);
    }

    @ApiOperation("根据skuId查询sku信息")
    @GetMapping("/getProductSkuBySkuId/{skuId}")
    public ProductSkuDetailRespDto getProductSkuBySkuId(@PathVariable Long skuId){
        return productService.getProductSkuDtoBySkuId(skuId);
    }

}
